package com.relytosoft.mizar.media.analyze.services.controller.behavior;

import com.relytosoft.dubhe.common.core.object.ResponseResult;
import com.relytosoft.mizar.media.analyze.services.controller.AyDataBaseController;
import com.relytosoft.mizar.media.analyze.services.service.behavior.AyBehaviorDataService;
import com.relytosoft.mizar.media.common.entity.pojo.request.btdl.common.BtdlBehaviorDataReq;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Objects;

/**
 * @author wss
 * @version 1.0
 * @date 2022/6/14 9:25
 */
@RestController
@RequestMapping("/analyze/behavior/data")
@Api(tags = "行为分析接收算法推送数据接口")
public class AyBehaviorDataController extends AyDataBaseController {

    @Autowired
    private AyBehaviorDataService ayBehaviorDataService;

    @ApiOperation(value = "原始数据接收")
    @PostMapping(value = "/raw")
    public ResponseResult receiveRawData(HttpServletRequest request) {
        BtdlBehaviorDataReq btdlBehaviorDataReq = toBehaviorDataReq(request);
        if (Objects.isNull(btdlBehaviorDataReq)) {
            return ResponseResult.fail();
        }
        ayBehaviorDataService.receiveRawData(btdlBehaviorDataReq);
        return ResponseResult.ok();
    }

}
